package cn.cs.service;

import cn.cs.mapper.UserBalanceMapper;
import cn.cs.pojo.UserBalance;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


@RestController
public class UserBalanceService {

    @Resource
    private UserBalanceMapper userBalanceMapper;

    //根据用户id 查询账户余额
    @RequestMapping(value = "/getUserBalanceById", method = RequestMethod.POST)
    public UserBalance getUserBalanceById(@RequestParam("userId") String userId)throws Exception{
        return userBalanceMapper.getUserBalanceById(userId);
    }


    @RequestMapping(value = "/updateBalance", method = RequestMethod.POST)
    public Integer updateBalance(@RequestBody Map<String, Object> param) throws Exception{
        return userBalanceMapper.updateBalance(param);
    }

    @RequestMapping(value = "/getUserBalanceListByMap", method = RequestMethod.POST)
    public List<Map<String,Object>>	getUserBalanceListByMap(@RequestBody Map<String, Object> param)throws Exception{
        return userBalanceMapper.getUserBalanceListByMap(param);
    }

    @RequestMapping(value = "/getUserBalanceCountByMap", method = RequestMethod.POST)
    public Integer getUserBalanceCountByMap(@RequestBody Map<String, Object> param)throws Exception{
        return userBalanceMapper.getUserBalanceCountByMap(param);
    }

    @RequestMapping(value = "/addUserBalance", method = RequestMethod.POST)
    public Integer addUserBalance(@RequestBody UserBalance userBalance)throws Exception{
        return userBalanceMapper.insertUserBalance(userBalance);
    }

    @RequestMapping(value = "/modifyUserBalance", method = RequestMethod.POST)
    public Integer modifyUserBalance(@RequestParam("balance") String balance, @RequestParam("id") String id)throws Exception{
        return userBalanceMapper.updateUserBalance(balance, id);
    }

    @RequestMapping(value = "/deleteUserBalanceById", method = RequestMethod.POST)
    public Integer deleteUserBalanceById(@RequestParam("id") Long id)throws Exception{
        return userBalanceMapper.deleteUserBalanceById(id);
    }

    @RequestMapping(value = "/updateUserBalanceNew", method = RequestMethod.POST)
    public Integer updateUserBalanceNew(@RequestParam("id") String id, @RequestParam("balance") String balance)throws Exception{
        return userBalanceMapper.updateUserBalanceNew(id, balance);
    }



}
